cisco 2612

Learn about cisco 2612, we have the largest and most updated cisco 2612 information on alibabacloud.com

BFS (Shortest path) HDU 2612 Find a way

;BayiQ.push (Make_pair (TX, Ty)); Vis[tx][ty] =true; the } the } - } - the intMainvoid) {//HDU 2612 Find a the while(SCANF ("%d%d", n, m) = =2) { the for(intI=1; ii) { thescanf ("%s", Maze[i] +1); - for(intj=1; jj) { the if(Maze[i][j] = ='Y') SX = i, sy =J; the if(Maze[i][j] = ='M') ex = i, EY =J; the }94 } the bfs_y (); Bfs_m (); the intAns =INF; th

C-Language BFS (4) ___find A (Hdu 2612)

problem DescriptionPass a year learning in Hangzhou, Yifenfei arrival hometown Ningbo at finally. Leave Ningbo One year, Yifenfei has many people to meet. Especially a good friend Merceki.Yifenfei's home is on the countryside, but Merceki's home is in the center of the city. So Yifenfei made arrangements and Merceki to meet at a KFC. There is many KFC in Ningbo, they want to choose one and the total time to it is most smallest.Now give your a Ningbo map, Both Yifenfei and Merceki can move up, do

HDU 2612-find A-on-the-it (detail BFS)

Topic Link: Find A-toThe topic is not difficult, a few days ago, at that time prepared to write two-way BFS, and then deal with the details of some problems, to catch up with something on hold. Rewrite this evening, no two-way, with two times BFS search, and two-way BFS almost the same principle. It's just a little hole in the problem, you need to be careful.1.Y cannot go through M. M cannot go through Y. In other words, Y and M are squares that can be thought of as walls.2. KFC must be both Y a

Codevs 2612 Most decomposition scheme (greedy)

/*number is not duplicated*/#include#include#include#defineMAXN 2600using namespacestd;intN,ANS[MAXN],L,P[MAXN];voidMul (intx) { for(intI=1; i) Ans[i]=ans[i]*x; for(intI=1; i) if(ans[i]>9) {ans[i+1]+=ans[i]/Ten; Ans[i]=ans[i]%Ten; } while(ans[l+1]) {L++; Ans[l+1]+=ans[l]/Ten; ANS[L]=ans[l]%Ten; }}intMain () {scanf ("%d",N); inti,k,s=0; for(i=2; i;i++) { if(n-i0) Break; N=n-i;p[++s]=i; } k=N; while(k) for(inti=s;i>=1; i--) if(k) {P[i]++;k--; } ans[1]=1; L=1;

Figure BFS-HDU 1241/HDU 2612/poj 3984

This is completely a review of previous knowledge... some familiar methods gradually emerged when I was writing ........-- In fact, the questions are very watery... but for the sake of my wa, I posted it .... HDU 1241 # Include HDU 2612 I can't brush too many questions at night, so my mind is dizzy... this question is wa to death. wa to death .... First, the array of the result (KFC) is reduced, so that only maxn is available. In fact,

Hdu-2612-find A (BFS)

Find A-toTime limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)Total submission (s): 6157 Accepted Submission (s): 2052Problem Descriptionpass a year learning in Hangzhou, Yifenfei arrival hometown Ningbo at finally. Leave Ningbo One year, Yifenfei has many people to meet. Especially a good friend Merceki.Yifenfei's home is on the countryside, but Merceki's home is in the center of the city. So Yifenfei made arrangements and Merceki to meet at a KFC. There is many KFC i

hdu-2612 two times BFS

http://acm.hdu.edu.cn/showproblem.php?pid=2612Two BFs, record the shortest time for each KFC. Select the shortest time.#include hdu-2612 two times BFS

HDU 2612 find a way

Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2612 Q: It takes the shortest time for Y and m to go to the same KFC (there may be multiple KFC instances) My method is to search for the sum of the shortest time of two people from KFC. The only thing that hurts is the first few of TLE's. Yes. /** Danceonly*/#include

HDU 2612.Find A

Find A-to Time limit:1000MS Memory Limit:32768KB 64bit IO Format:%i64d %i64 U Submit Status Practice HDU 2612 DescriptionPass a year learning in Hangzhou, Yifenfei arrival hometown Ningbo at finally. Leave Ningbo One year, Yifenfei has many people to meet. Especially a good friend Merceki. Yifenfei's home is on the countryside, but Merceki's home is in the center of the city. So Yifenfei made arrangements and Merceki to meet at a KFC

HDU-2612-Find a way

HDU-2612-Find a way Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2612 Calculate the sum of the distance between the two points and KFC to minimize it. Use BFS twice to obtain the shortest distance between the two points and each KFC, and then find the minimum and minimum values. # Include

HDU 2612 find a way (BFS + priority queue)

] [flag] = in. time;For (I = 0; I {Cur. x = in. x + dir [I] [0];Cur. Y = in. Y + dir [I] [1];If (Map [cur. x] [cur. Y]! = '#' Judge (cur. X, cur. y )){Mark [cur. x] [cur. Y] = 1;Cur. Time = in. Time + 11;Q. Push (cur );}}}Return 1;}Int main (){Int I, j, Sx, Sy, dx, Dy, Min, Q;While (scanf ("% d", N, M )! = EOF){Min = inf;For (I = 1; I Scanf ("% s", map [I] + 1 );For (I = 1; I For (j = 1; j For (q = 0; q Dis [I] [J] [Q] = inf;For (I = 1; I For (j = 1; j {If (Map [I] [J] = 'y '){Memset (mark, 0

HDU 2612-find A

while(!qb.empty ()) + { -now=Qb.front (); Qb.pop (); $ for(i=0;i4;++i) $ { -nxt.x=now.x+d[i][0]; -nxt.y=now.y+d[i][1]; thenxt.t=now.t+1; - if(Check (NXT) !Vis2[nxt.x][nxt.y])Wuyi { thevis2[nxt.x][nxt.y]=nxt.t; - Qb.push (NXT); Wu } - } About } $ } - intMain () - { - inti,j; A while(~SCANF ("%d%d",n,m)) + { the for(i=0; i) - { $scanf"%s", Map[i]); the for(j=0; j) the {

Find A---hdu--2612

one of the KFC. Sure there is always has a KFC that can let them meet.Sample Input4 4y.#@.....#. @.. M4 4y.#@.....#. @#. M5 5[email protected].#....#...@. m.#...#Sample Output668866Code:#include #include#include#include#include#includeusing namespacestd;#defineINF 0x3f3f3f3f#defineN 210structnode{intx, y, step;};intN, M, A[n][n], dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};CharG[n][n];intVis[n][n];voidBFS (node S,intnum) {node p, q; Queuep; Q.push (s); memset (Vis,0,sizeof(VIS)); VIS[S.X][S.Y]=

HDU 2612 Water BFS

Two persons (Y and M) to meet at the ' @ ', there is an indefinite ' @ ' in the picture;Do the BFS once for everyone, then enumerate each ' @ ' position#include "stdio.h" #include "string.h" #include "queue" using namespace std;const int Inf=0x7fffffff;const int dir[4][2]={ {1,0},{-1,0},{0,1},{0,-1}};struct node{int x,y,t;}; int Y_n,y_m,m_n,m_m,n,m;char str[210][210];int sum[210][210],mark[210][210];int Min (int a,int b) {if (aHDU 2612 Water BFS

HDU 2612 Find A (BFS)

[next.x][next.y]!='M') {vis[next.x][next.y][opt]=vis[now.x][now.y][opt]+1; Q.push (next); } } } return ;}intMain () { while(SCANF ("%d%d", n,m)! =EOF) {memset (Mat,0,sizeof(MAT)); for(intI=0; i) {scanf ("%s", Mat[i]); for(intj=0; j) { if(mat[i][j]=='Y') SX=i,sy=J; if(mat[i][j]=='M') Ex=i,ey=J; }} memset (Vis,0,sizeof(VIS)); BFS (Sx,sy,0); BFS (Ex,ey,1); Ans=INF; for(intI=0; i) { for(intj=0; j) { if(

Hdoj-2612-find a way-two-way BFS

Find A-toTime limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)Total submission (s): 4854 Accepted Submission (s): 1650Problem Descriptionpass a year learning in Hangzhou, Yifenfei arrival hometown Ningbo at finally. Leave Ningbo One year, Yifenfei has many people to meet. Especially a good friend Merceki.Yifenfei's home is on the countryside, but Merceki's home is in the center of the city. So Yifenfei made arrangements and Merceki to meet at a KFC. There is many KFC in

HDU-2612 Find A-a-

Idea: A question of pleasure than all do not explain the topic is good, let me re-understand the effectiveness of BFS. In fact, the idea is very easy, is to traverse the next two people to each ' @ ' distance, save it and then see which of the shortest line, the key problem isdata structure, that is, the storage and operation of the method. At first, my idea was to map the distance from each point to the walking person to the coordinates of the point, but I stuck in the distance, but I al

HDU 2612 Find A

() - { A while(cin>>n>>L) { + for(intI=1; i) the for(intj=1; j){ -Cin>>A[i][j]; $ if(a[i][j]=='Y'){//record the position of Y theycurx=i; theycury=J; the } the Else if(a[i][j]=='M'){//record M's position -mcurx=i; inmcury=J; the } the } About intTmin =999999999; theBFS (Ycurx,ycury);//begin breadth-first search with (Ycurx,ycury) as a starting point the for(intI=1; i) the

HDU 2612 Find A-A-(double BFS)

"Y" and "M ' two people to a KFC (denoted by" @ "on the map) the minimum time and how much they need for the map to N*m. They take 11 minutes each step.You can start with Y and M, respectively. BFS to save the time to each KFC and finally see which KFC's time and the smallest.#include Find A-toProblem Descriptionpass a year learning in Hangzhou, Yifenfei arrival hometown Ningbo at finally. Leave Ningbo One year, Yifenfei has many people to meet. Especially a good friend Merceki.Yifenfei's home i

Simple HDU 2612 Find a way,bfs.

) return 0; return 1;}voidBFsintXintYint(*rem) [205]) {las=fir=0; intcou=0; inttemp,t1,t2; Que[las++]=x* ++y; Rem[x][y]=0; while(las-fir) {Temp=que[fir++]; T1=temp/ +; T2=temp% +; Temp=REM[T1][T2]; if(map1[t1][t2]==2) ++cou; if(cou>=COUKFC)return; --T1; if(judge (T1,t2,rem)) {Rem[t1][t2]=temp+1; Que[las++]=t1* ++T2; } T1+=2; if(judge (T1,t2,rem)) {Rem[t1][t2]=temp+1; Que[las++]=t1* ++T2; } --T1; --T2; if(judge (T1,t2,rem)) {Rem[t1][t2]=temp+1; Que[las++]=t1* ++T2; }

Total Pages: 15 1 2 3 4 5 .... 15 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.